package spider

import (
	"fmt"
	"log"
	"time"
)

const (
	prefix = "https://www.i275.com"
)

func Run(seed string, dest string, start int) {
	graber := NewMenuGraber()
	audioGraber := NewAudioGraber()
	downloader := NewDownloader(dest)

	menus := graber.GrabMenu(seed)

	for i, menu := range menus {
		if i+1 <= start {
			continue
		}
		audio := audioGraber.Grab(menu)
		downloader.Download(audio)
		log.Printf("downloaded file: %v\n", audio.Name)
		if (i+1)%8 == 0 {
			time.Sleep(5 * time.Minute)
		}
	}
	fmt.Println("Finally ! we are completed succesfully")
}
